package leetcode.easy.limit50;

/**
 * @author liuyy
 * @className No26
 * @description TODO
 * @date 2019/10/30 15:57
 **/
public class No26 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 1, 2};
        No26 no26 = new No26();
        int i = no26.removeDuplicates(nums);
        System.out.println(i);
        for (int i1 = 0; i1 < i; i1++) {
            System.out.println(nums[i1]);
        }
    }

    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int fast = 0;
        int slow = 0;
        while (fast < nums.length) {
            if (nums[fast] != nums[slow]) {
                slow++;
                nums[slow] = nums[fast];
            }
            fast++;
        }
        return slow + 1;
    }


}
